#!/usr/bin/env bash

SILENT=$2
LINE_LENGTH=72
LAST_TAG=$(git describe --abbrev=0)

if [ -n "$1" ]; then
    LAST_TAG=$1
else
    if [ "$SILENT" != "silent" ]; then
        echo "Changes since $LAST_TAG:"
    fi
fi

git log --format=%s ${LAST_TAG}..HEAD | \
  grep -v "Updates for release" | \
  grep -v "Update translation" | \
  grep -v "Add new translation" | \
  grep -v "Back to development" | \
  while read line; do \
    echo "- $line" | \
    fold -s -w $LINE_LENGTH | \
    sed -e "s/^[^ ]/&/g"
  done
